<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: janolaw.php 60 2013-09-21 11:58:55Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 60 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:58:55 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');

if (isset($_GET['action']) && $_GET['action'] == 'save') {
	$janolaw = $db->db_query("SELECT 
									configuration_key
								FROM 
									".TABLE_CONFIGURATION." 
								WHERE 
									configuration_group_id = '24' 
								ORDER BY 
									sort_order");

	while (!$janolaw->EOF) {
		$db->db_query("UPDATE 
							".TABLE_CONFIGURATION." 
						SET 
							configuration_value = '".$_POST[$janolaw->fields['configuration_key']]."'
						WHERE 
							configuration_key = '".$janolaw->fields['configuration_key']."'");
		$janolaw->MoveNext();
	}
	redirect(href_link('janolaw.php'));
}
require(DIR_WS_INCLUDES.'metatag.php'); ?>
</head>
<body>
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<div id="wrapper">
	<table class="outerTable">
		<tr>
 			<td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
				<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
			</td>
	     	<td class="boxCenter" valign="top">
				<table class="table_pageHeading" border="0" width="100%" cellspacing="0" cellpadding="0">
		    		<tr>
		     			<td class="pageHeading">
		        			<?php echo HEADING_TITLE; ?>
		     			</td>
		   			</tr>
		   		</table>
				<table border="0" width="100%" cellpadding="2">
					<tr>
			            <td valign="top" align="right">
							<?php echo draw_form('janolaw', 'janolaw.php', 'action=save'); ?>
			            	<table width="100%"  border="0" cellspacing="0" cellpadding="4">
			            		<tr>
									<td colspan="2">
										<?php
											if(function_exists(curl_init)) {
												$data = curl_init('http://www.janolaw.de/internetrecht/agb/agb-hosting-service/seo_mecari-header.html');
												curl_setopt($data, CURLOPT_RETURNTRANSFER, 1);
												$output = curl_exec($data);

												curl_close($data);

											} elseif ($file = file_get_contents('http://www.janolaw.de/internetrecht/agb/agb-hosting-service/seo_mecari-header.html')) {
												$output = $file;

											} else {
												$host = 'janolaw.de';
												$uri  = '/internetrecht/agb/agb-hosting-service/seo_mecari-header.html';

												header("Content-type: text/plain");
												$sock = fsockopen($host, 80, $errno, $errstr, 5);
												fputs($sock, "GET ".$uri." HTTP/1.1\r\n");
												fputs($sock, "Host: ".$host."\r\n");
												fputs($sock, "Connection: close\r\n\r\n");
												$result = array();
												while(!feof($sock))
													$result[] = fgets($sock, 4096);
												fclose($sock);
												if(!empty($result['1'])) {
													for($i = 1, $size = sizeof($result); $i < $size; ++$i) {
														if(!empty($result[$i]) || $result[$i] !='0')
															$output .= $result[$i];
													}
												}
											}
											echo utf8_encode($output);
										?>
									</td>
								</tr>
								<?php
								$janolaw = $db->db_query("SELECT 
																configuration_key,
																configuration_id,
																configuration_value,
																use_function,set_function
															FROM ".TABLE_CONFIGURATION." 
															WHERE 
																configuration_group_id = '24' 
															ORDER BY 
																sort_order");
								while (!$janolaw->EOF) {
									if (not_null($janolaw->fields['use_function'])) {
										$use_function = $janolaw->fields['use_function'];
										if (preg_match('/->/', $use_function)) {
											$class_method = explode('->', $use_function);
											if (!is_object(${$class_method[0]})) {
												include(DIR_WS_CLASSES.$class_method[0].'.php');
												${$class_method[0]} = new $class_method[0]();
											}
											$cfgValue = call_function($class_method[1], $janolaw->fields['configuration_value'], ${$class_method[0]});
										} else
											$cfgValue = call_function($use_function, $janolaw->fields['configuration_value']);
									
									} else
										$cfgValue = $janolaw->fields['configuration_value'];
									
									if ($configuration->fields['set_function'])
										eval('$value_field = '.$janolaw->fields['set_function'].'"'.htmlspecialchars($janolaw->fields['configuration_value']).'");');
									else
										$value_field = draw_input_field($janolaw->fields['configuration_key'], $janolaw->fields['configuration_value'], 'class="input_config"');
									
									if (strstr($value_field,'configuration_value'))
										$value_field = str_replace('configuration_value',$janolaw->fields['configuration_key'],$value_field);
									
									if ($i % 2 == 0) $f = '';
									else $f = 'dataTableRow';
									echo '	<tr class="'.$f.'" >
												<td width="30%" valign="top" style="border-top: 1px solid #ccc">
													<b>'.constant(strtoupper($janolaw->fields['configuration_key'].'_TITLE')).'</b>
												</td>
												<td valign="top" align="left" style="border-top: 1px solid #ccc">
													<p>'.constant(strtoupper($janolaw->fields['configuration_key'].'_DESC')).'</p>
													'.$value_field.'
												</td>
											</tr>';
									
									$i++;
									$janolaw->MoveNext();
								}
								?>
								<tr>
				      				<td align="right" colspan="2">
					    				<button type="submit" class="button" onclick="this.blur();"><?php echo BUTTON_SAVE ?></button>
					    			</td>
				      			</tr>
							</table>
						</td>
					</tr>
        		</table>
			</td>
      	</tr>
	</table>
</div>
<?php require(DIR_WS_INCLUDES.'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES.'application_bottom.php');